/*
 * @Author: C.
 * @Date: 2022-06-06 16:27:23
 * @LastEditTime: 2022-09-28 12:20:11
 * @Description: file content
 */
// 判断arr是否为一个数组，返回一个bool值
function isArray(arr) {
  return Object.prototype.toString.call(arr) === "[object Array]";
}
export function treeEditTableDataInit(data, children = "Children") {
  if (!isArray(data) || data.length == 0) return data;
  return data.map((item) => {
    if (item.hasOwnProperty(children)) {
      return {
        IsEdit: false,
        ...item,
        [children]: treeEditTableDataInit(item[children], children),
      };
    } else {
      return {
        IsEdit: false,
        ...item,
      };
    }
  });
}
